package com.ctshk.rpc.certificate.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

public class OrderUtil {

    public static final String yyMMdd = "yyMMdd";
    public static final String HHmmss = "HHmmss";
    public static final String HH_mm_ss = "HH:mm:ss";
    public static final String yyyyMMdd = "yyyyMMdd";
    public static final String yyyy_MM_dd = "yyyy-MM-dd";
    public static final String yyMMddHHmmss = "yyMMddHHmmss";
    public static final String yyyyMMddHHmm = "yyyyMMddHHmm";

    /**
     * 获取随机数2
     */
    public static String getRandom2() {
        Random random = new Random();
        int ends = random.nextInt(99);
        return String.format("%02d", ends);
    }

    /**
     * 获取随机数6
     */
    public static String getRandom6() {
        Random random = new Random();
        int ends = random.nextInt(999999);
        return String.format("%06d", ends);
    }

    /**
     * 获取随机数3
     */
    public static String getRandom3() {
        Random random = new Random();
        int ends = random.nextInt(999);
        return String.format("%03d", ends);
    }

    /**
     * 获取回乡证单号
     *  ZJBL+預約時間+6位數的隨機碼
     */
    public static String getReentryPermitRegisterNumber() {
        LocalDateTime now = LocalDateTime.now();
        return "ZJBL"+now.format(DateTimeFormatter.ofPattern(yyyyMMddHHmm)) + getRandom6();
    }

    /**
     * 获取星期几
     */
    public static String getWeekOfDate(LocalDateTime now) {
        String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
        return weekDays[now.getDayOfWeek().getValue() - 1];
    }

    /**
     * 获取日期和星期几
     */
    public static String getDayAndWeek(LocalDateTime now) {
        return now.format(DateTimeFormatter.ofPattern(yyyyMMdd)) + " " + OrderUtil.getWeekOfDate(now);
    }
}
